// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   CourseAction.java

package com.iphaeton.lms.action.course.scorm12;

import com.iphaeton.common.helper.Pagination;
import com.iphaeton.common.helper.UserSession;
import com.iphaeton.exception.BusinessException;
import com.iphaeton.lms.business.course.scorm12.ICourseService;
import com.iphaeton.lms.business.organize.IOrganizeService;
import com.iphaeton.lms.pojo.course.Course;
import com.iphaeton.lms.pojo.organize.Organize;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import org.apache.log4j.Logger;
import org.apache.struts.action.*;
import org.dom4j.io.XMLWriter;

// Referenced classes of package com.iphaeton.lms.action.course.scorm12:
//            CourseBizSupportAction

public class CourseAction extends CourseBizSupportAction
{

	
    private DynaActionForm daf;
    private Pagination pageInfo;
    private static Logger logger= Logger.getLogger(com.iphaeton.lms.action.course.scorm12.CourseAction.class.getName());
    
    

    public ActionForward findCourse(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        daf = (DynaActionForm)form;
        int pageSize = 10;
        int currentPage = 1;
        String strPage = request.getParameter("page");
        List courseList = null;
        try
        {
            if(strPage == null || strPage.trim().equals(""))
            {
                pageInfo = course.findCourse("a", pageSize);
                pageInfo.setPage(currentPage);
            } else
            if(strPage != null && !strPage.trim().equals(""))
            {
                currentPage = Integer.parseInt(strPage);
                pageInfo = (Pagination)request.getSession().getAttribute("pageInfo");
                pageInfo.setPage(currentPage);
            }
            courseList = course.findPageList(pageInfo);
            request.getSession().setAttribute("pageInfo", pageInfo);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("course", courseList);
        return mapping.findForward("course_list");
    }

    public ActionForward findSortCourse(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        daf = (DynaActionForm)form;
        int pageSize = 10;
        int currentPage = 1;
        String strPage = request.getParameter("page");
        String sort_id = request.getParameter("sortId");
        if(sort_id == null)
            sort_id = "";
        List courseList = null;
        try
        {
            String id = ((UserSession)request.getSession().getAttribute("userSession")).getManageOrgId();
            if(strPage == null || strPage.trim().equals(""))
            {
                pageInfo = course.findSortCourse("a", sort_id, id, pageSize);
                pageInfo.setPage(currentPage);
            } else
            if(strPage != null && !strPage.trim().equals(""))
            {
                currentPage = Integer.parseInt(strPage);
                pageInfo = (Pagination)request.getSession().getAttribute("pageInfo");
                pageInfo.setPage(currentPage);
            }
            courseList = course.findPageList(pageInfo);
            request.getSession().setAttribute("pageInfo", pageInfo);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        request.setAttribute("sort_id", sort_id);
        request.setAttribute("course", courseList);
        return mapping.findForward("course_list");
    }

    public ActionForward assignOrganizeCourse(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String id = request.getParameter("id");
        Organize org;
        try
        {
            org = organize.findOrganizeById(id);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("organize", org);
        return mapping.findForward("organize_course_assign");
    }

    public ActionForward assignCourse(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String orgId = request.getParameter("organizeSel");
        String courseId = request.getParameter("courseSel");
        List list = new LinkedList();
        String strCourseId[] = courseId.split("&");
        String strOrgId[] = orgId.split("&");
        try
        {
            for(int i = 0; i < strCourseId.length; i++)
            {
                for(int j = 0; j < strOrgId.length; j++)
                {
                    List orgCourse = new LinkedList();
                    Course c = course.findCourseById(strCourseId[i]);
                    Organize o = organize.findOrganizeById(strOrgId[j]);
                    course.assignCourse(c, o);
                    orgCourse.add(o.getUrl());
                    orgCourse.add(c.getName());
                    list.add(orgCourse);
                }

            }

        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("list", list);
        return mapping.findForward("organize_course");
    }

    public ActionForward courseSort(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String id = request.getParameter("id");
        if(id == null)
            id = "";
        List list = null;
        try
        {
            list = course.findCourseSort();
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("id", id);
        request.setAttribute("list", list);
        return mapping.findForward("course_import");
    }

    public ActionForward selectCourseSort(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        List list = null;
        try
        {
            list = course.findCourseSort();
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("list", list);
        return mapping.findForward("course_sort_list");
    }

    public ActionForward addCourseSort(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        List list = null;
        String sort = request.getParameter("sort");
        String comment = request.getParameter("comment");
        try
        {
            course.addCourseSort(sort, comment);
            list = course.findCourseSort();
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("list", list);
        return mapping.findForward("course_sort_list");
    }

    public ActionForward findCourseSort(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String id = request.getParameter("id");
        com.iphaeton.lms.pojo.course.CourseSort cs = null;
        try
        {
            cs = course.findCourseSort(id);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("cs", cs);
        return mapping.findForward("course_sort_detail");
    }

    public ActionForward editCourseSort(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String id = request.getParameter("id");
        String name = request.getParameter("name");
        String comment = request.getParameter("comment");
        List list = null;
        try
        {
            course.updateCourseSort(id, name, comment);
            list = course.findCourseSort();
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("list", list);
        return mapping.findForward("course_sort_list");
    }

    public ActionForward deleteCourseSort(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String id = request.getParameter("id");
        List list = null;
        try
        {
            course.deleteCourseSort(id);
            list = course.findCourseSort();
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("list", list);
        return mapping.findForward("course_sort_list");
    }

    public ActionForward removeCourse(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String id[] = request.getParameter("id").split(";");
        try
        {
            for(int i = 0; i < id.length; i++)
            {
                Course c = course.findCourseById(id[i]);
                course.removeCourse(c);
                c.setOrganize(null);
                c.setCourseUser(null);
                course.persistent(c);
            }

        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        return mapping.findForward("courseList");
    }

    public ActionForward getCourseDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        org.dom4j.Document doc = null;
        try
        {
            String organize_id = ((UserSession)request.getSession().getAttribute("userSession")).getManageOrgId();
            doc = course.getCourseDocument(organize_id);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        response.setContentType("text/xml; charset=UTF-8");
        javax.servlet.ServletOutputStream sos = response.getOutputStream();
        XMLWriter writer = new XMLWriter(sos);
        writer.write(doc);
        writer.flush();
        writer.close();
        return null;
    }

    public ActionForward selectOrganize(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String courseList = request.getParameter("courseList");
        Organize org = null;
        String str = "";
        try
        {
            String organizeId = ((UserSession)request.getSession().getAttribute("userSession")).getManageOrgId();
            org = organize.findOrganizeById(organizeId);
            str = organize.getOrgCkBTree(org, "tree");
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        request.setAttribute("str", str);
        request.setAttribute("courseList", courseList);
        return mapping.findForward("organize_choice");
    }

    public ActionForward findSelCourseStu(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String row = request.getParameter("row");
        String strPage = request.getParameter("page");
        String strState = request.getParameter("state");
        String courseId = request.getParameter("courseId");
        if(courseId == null)
            courseId = "";
        String sortId = request.getParameter("sortId");
        if(sortId == null)
            sortId = "";
        int state = Integer.parseInt(strState);
        int pageSize = 10;
        int currentPage = 1;
        List list = null;
        try
        {
            if(strPage != null && !strPage.trim().equals(""))
                currentPage = Integer.parseInt(strPage);
            pageInfo = course.findSelCourseStu(sortId, courseId, row, state, pageSize);
            pageInfo.setPage(currentPage);
            pageInfo.setRow(row);
            pageInfo.setState(state);
            list = course.findPageList(pageInfo);
            request.getSession().setAttribute("pageInfo", pageInfo);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("courseId", courseId);
        request.setAttribute("sortId", sortId);
        request.setAttribute("list", list);
        return mapping.findForward("course_apply_stu");
    }

    public ActionForward selectCourse(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        int pageSize = 10;
        int currentPage = 1;
        String id = request.getParameter("id");
        String strPage = request.getParameter("page");
        String row = request.getParameter("row");
        List list = null;
        Organize org = null;
        try
        {
            if(id == null || "".equals(id))
                id = ((UserSession)request.getSession().getAttribute("userSession")).getManageOrgId();
            org = organize.findOrganizeById(id);
            if(strPage != null && !strPage.trim().equals(""))
                currentPage = Integer.parseInt(strPage);
            pageInfo = course.selectCourse(id, pageSize);
            pageInfo.setPage(currentPage);
            pageInfo.setRow(row);
            list = course.selectCourse(id, row, pageSize, currentPage);
            request.getSession().setAttribute("pageInfo", pageInfo);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("organize", org);
        request.setAttribute("list", list);
        return mapping.findForward("organize_course_list");
    }

    public ActionForward removeCourseFromOrg(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        int pageSize = 10;
        int currentPage = 1;
        String strPage = request.getParameter("page");
        String row = request.getParameter("row");
        List list = null;
        Organize org = null;
        String orgId = request.getParameter("orgId");
        String id = request.getParameter("id");
        String courseId[] = id.split(";");
        try
        {
            for(int i = 0; i < courseId.length; i++)
                course.removeCourseFromOrg(orgId, courseId[i]);

            org = organize.findOrganizeById(orgId);
            if(strPage != null && !strPage.trim().equals(""))
                currentPage = Integer.parseInt(strPage);
            pageInfo = course.selectCourse(orgId, pageSize);
            pageInfo.setPage(currentPage);
            list = course.selectCourse(orgId, row, pageSize, currentPage);
            request.getSession().setAttribute("pageInfo", pageInfo);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("organize", org);
        request.setAttribute("list", list);
        return mapping.findForward("organize_course_list");
    }

    public ActionForward courseSelectManage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        int pageSize = 10;
        int currentPage = 1;
        String strPage = request.getParameter("page");
        String row = request.getParameter("row");
        int state = 0;
        if(request.getParameter("state") == null || "".equals(request.getParameter("state")))
            state = 1;
        else
            state = Integer.parseInt(request.getParameter("state"));
        UserSession userSession = (UserSession)request.getSession().getAttribute("userSession");
        String orgId = userSession.getOrgId();
        String userId = userSession.getId();
        List list = null;
        try
        {
            String orgUrl = organize.findOrganizeById(orgId).getUrl();
            if(strPage != null && !strPage.trim().equals("") && !strPage.trim().equals("0"))
                currentPage = Integer.parseInt(strPage);
            pageInfo = course.courseSelectManage(orgUrl, userId, state, pageSize);
            pageInfo.setPage(currentPage);
            pageInfo.setRow(row);
            pageInfo.setState(state);
            list = course.courseSelectManage(orgUrl, userId, row, state, pageSize, currentPage);
            request.getSession().setAttribute("pageInfo", pageInfo);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("list", list);
        return mapping.findForward("course_select_list");
    }

    public ActionForward courseSelected(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        int pageSize = 10;
        int currentPage = 1;
        String strPage = request.getParameter("page");
        String row = request.getParameter("row");
        int state = 0;
        if(request.getParameter("state") == null || "".equals(request.getParameter("state")))
            state = 4;
        else
            state = Integer.parseInt(request.getParameter("state"));
        List list = null;
        try
        {
            UserSession userSession = (UserSession)request.getSession().getAttribute("userSession");
            String orgId = userSession.getOrgId();
            String orgUrl = organize.findOrganizeById(orgId).getUrl();
            String userId = userSession.getId();
            if(strPage != null && !strPage.trim().equals("") && !strPage.trim().equals("0"))
                currentPage = Integer.parseInt(strPage);
            pageInfo = course.courseSelectManage(orgUrl, userId, state, pageSize);
            pageInfo.setPage(currentPage);
            pageInfo.setRow(row);
            pageInfo.setState(state);
            list = course.courseSelectManage(orgUrl, userId, row, state, pageSize, currentPage);
            request.getSession().setAttribute("pageInfo", pageInfo);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        request.setAttribute("list", list);
        return mapping.findForward("course_selected");
    }

    public ActionForward applyCourse(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String id = request.getParameter("id");
        String courseId[] = id.split("&");
        try
        {
            UserSession userSession = (UserSession)request.getSession().getAttribute("userSession");
            String userId = userSession.getId();
            for(int i = 0; i < courseId.length; i++)
                course.applyCourse(courseId[i], userId);

        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        return mapping.findForward("courseSelected");
    }

    public ActionForward removeCourseApply(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String id = request.getParameter("id");
        String arrId[] = id.split("&");
        try
        {
            for(int i = 0; i < arrId.length; i++)
                course.removeCourseApply(arrId[i]);

        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        return mapping.findForward("courseConfuse");
    }

    public ActionForward approveCourseApply(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String id = request.getParameter("id");
        String arrId[] = id.split("&");
        try
        {
            for(int i = 0; i < arrId.length; i++)
                course.approveCourseApply(arrId[i]);

        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        return mapping.findForward("courseApprove");
    }

    public ActionForward myCourse(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String row = request.getParameter("row");
        List list = null;
        try
        {
            UserSession userSession = (UserSession)request.getSession().getAttribute("userSession");
            String userId = userSession.getId();
            list = course.mySelectedCourse(userId, row);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        request.setAttribute("list", list);
        return mapping.findForward("my_course");
    }

    public ActionForward myCourseInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String row = request.getParameter("row");
        List list = null;
        try
        {
            UserSession userSession = (UserSession)request.getSession().getAttribute("userSession");
            String userId = userSession.getId();
            list = course.mySelectedCourse(userId, row);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        request.setAttribute("list", list);
        return mapping.findForward("my_course_info");
    }

    public ActionForward studyInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String row = request.getParameter("row");
        String userId = request.getParameter("id");
        List list = null;
        try
        {
            list = course.mySelectedCourse(userId, row);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("list", list);
        return mapping.findForward("study_info");
    }

    public ActionForward trainCourse(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String row = request.getParameter("row");
        List list = null;
        try
        {
            UserSession userSession = (UserSession)request.getSession().getAttribute("userSession");
            String userId = userSession.getId();
            list = course.myTrainCourse(userId, row);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        request.setAttribute("list", list);
        return mapping.findForward("train_course");
    }

    public ActionForward privateCourse(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String courseID = (String)request.getAttribute("cid");
        String organize_id = (String)request.getAttribute("oid");
        Course c = null;
        Organize org = null;
        try
        {
            c = course.findCourseById(courseID);
            org = organize.findOrganizeById(organize_id);
            course.assignCourse(c, org);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("course", c);
        return mapping.findForward("course_import_complete");
    }

    public ActionForward courseStudyInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        int pageSize = 10;
        int currentPage = 1;
        String sort = request.getParameter("course_sort");
        String strPage = request.getParameter("page");
        String row = request.getParameter("row");
        String courseId = request.getParameter("course_id");
        List list = null;
        try
        {
            String id = ((UserSession)request.getSession().getAttribute("userSession")).getManageOrgId();
            if(strPage != null && !strPage.trim().equals("") && !strPage.trim().equals("0"))
                currentPage = Integer.parseInt(strPage);
            pageInfo = course.courseStudyInfo(id, courseId, sort, row, pageSize);
            pageInfo.setPage(currentPage);
            pageInfo.setRow(row);
            list = course.findPageList(pageInfo);
            request.getSession().setAttribute("pageInfo", pageInfo);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        request.setAttribute("list", list);
        request.setAttribute("sort", sort);
        return mapping.findForward("course_study_list");
    }

    public ActionForward courseTree(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        response.setHeader("Pragma", "No-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0L);
        org.dom4j.Document doc = null;
        try
        {
            doc = course.getCourseSortTree();
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        response.setContentType("text/xml; charset=UTF-8");
        javax.servlet.ServletOutputStream sos = response.getOutputStream();
        XMLWriter writer = new XMLWriter(sos);
        writer.write(doc);
        writer.flush();
        writer.close();
        return null;
    }

    public ActionForward getCourseTree(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String type = request.getParameter("type");
        response.setHeader("Pragma", "No-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0L);
        org.dom4j.Document doc = null;
        try
        {
            String id = ((UserSession)request.getSession().getAttribute("userSession")).getManageOrgId();
            doc = course.getCourseTree(id, type);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        response.setContentType("text/xml; charset=UTF-8");
        javax.servlet.ServletOutputStream sos = response.getOutputStream();
        XMLWriter writer = new XMLWriter(sos);
        writer.write(doc);
        writer.flush();
        writer.close();
        return null;
    }

    public ActionForward sortCourseTree(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String id = request.getParameter("id");
        String type = request.getParameter("type");
        response.setHeader("Pragma", "No-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0L);
        org.dom4j.Document doc = null;
        try
        {
            String organize_id = ((UserSession)request.getSession().getAttribute("userSession")).getManageOrgId();
            doc = course.getSortCourseTree(organize_id, id, type);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        response.setContentType("text/xml; charset=UTF-8");
        javax.servlet.ServletOutputStream sos = response.getOutputStream();
        XMLWriter writer = new XMLWriter(sos);
        writer.write(doc);
        writer.flush();
        writer.close();
        return null;
    }

    public ActionForward courseApplyCount(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        int apply_count = 0;
        int study_count = 0;
        try
        {
            String id = ((UserSession)request.getSession().getAttribute("userSession")).getManageOrgId();
            String org_url = organize.findOrganizeById(id).getUrl();
            apply_count = course.findApplyUser(org_url, 2);
            study_count = course.findApplyUser(org_url, 1);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        request.setAttribute("apply_count", new Integer(apply_count));
        request.setAttribute("study_count", new Integer(study_count));
        return mapping.findForward("course_count");
    }

    
}
